package BanyuanClub.Study.Day0303;

import BanyuanClub.Study.Day0223.Object.A;

import java.util.Arrays;
import java.util.Comparator;

public class TextPerson {
    public static void main(String[] args) {
        Person[] persons = {new Person("ggg",20),
                new Person("ttt",35),
                new Person("fff",15)
        };
        //通过匿名内部类实现灵活的排序
        Arrays.sort(persons, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o2.getName().compareTo(o1.getName());
            }
        });

        //匿名内部类排序简易写法
        Arrays.sort(persons,(p1,p2)->{return p1.getAge() - p2.getAge();});
        System.out.println(Arrays.toString(persons));
    }
}
